"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _jsxRuntime = require("react/jsx-runtime");

var _proProvider = require("@ant-design/pro-provider");

var _antdV = require("antd-v4");

var _react = require("react");

require("./index.less");

var DropdownFooter = function DropdownFooter(props) {
  var intl = (0, _proProvider.useIntl)();
  var onClear = props.onClear,
      onConfirm = props.onConfirm,
      disabled = props.disabled,
      footerRender = props.footerRender;

  var _useContext = (0, _react.useContext)(_antdV.ConfigProvider.ConfigContext),
      getPrefixCls = _useContext.getPrefixCls;

  var prefixCls = getPrefixCls('pro-core-dropdown-footer');
  var defaultFooter = [(0, _jsxRuntime.jsx)(_antdV.Button, {
    style: {
      visibility: onClear ? 'visible' : 'hidden'
    },
    type: "link",
    size: "small",
    disabled: disabled,
    onClick: function onClick(e) {
      if (onClear) {
        onClear(e);
      }

      e.stopPropagation();
    },
    children: intl.getMessage('form.lightFilter.clear', '清除')
  }, "clear"), (0, _jsxRuntime.jsx)(_antdV.Button, {
    "data-type": "confirm",
    type: "primary",
    size: "small",
    onClick: onConfirm,
    disabled: disabled,
    children: intl.getMessage('form.lightFilter.confirm', '确认')
  }, "confirm")];

  if (footerRender === false || (footerRender === null || footerRender === void 0 ? void 0 : footerRender(onConfirm, onClear)) === false) {
    return null;
  }

  var renderDom = (footerRender === null || footerRender === void 0 ? void 0 : footerRender(onConfirm, onClear)) || defaultFooter;
  return (0, _jsxRuntime.jsx)("div", {
    className: prefixCls,
    onClick: function onClick(e) {
      return e.target.getAttribute('data-type') !== 'confirm' && e.stopPropagation();
    },
    children: renderDom
  });
};

var _default = DropdownFooter;
exports.default = _default;